package chap7;

import java.util.Comparator;
import java.util.Iterator;
import java.util.SortedSet;
import java.util.TreeSet;

public class ComparatorTest {
	public static void main(String args[]){
		SortedSet intSet=new TreeSet(new Comparator(){
		    public int compare(Object obj1, Object obj2){
		    	Integer o1 = (Integer)obj1;
		    	Integer o2 = (Integer)obj2;
		    	return o2.compareTo(o1);
		        //return o1.compareTo(o2);
		    }
		});
		intSet.add(new Integer(50));
		intSet.add(new Integer(25));
		intSet.add(new Integer(100));
		intSet.add(new Integer(-15));
		Iterator it=intSet.iterator();
		while(it.hasNext()){
		    System.out.println(it.next());
		}

	}
}
